import React from 'react';
import './style.css'

export default class CityList extends React.Component {
  constructor(props) {
    super(props);
    this.state={
      cities:["北京","杭州","上海","泰顺"]
    }
  }

  render() {
    console.log(this.state);
    return (
      <div>
        <h2>{this.props.cityName}</h2>
        <ul>
          {this.state.cities.map((item,index)=>{
            return (
              <li onClick={this.clickHandle.bind(this,item)} key={index}>{item}</li>
            )
          })}
        </ul>
      </div>
    )
  }
  clickHandle(key){
    // console.log(key)
    this.props.changeFn(key)
  }
}